package hub.cathome.controller;

import hub.annotation.Affairs;
import hub.annotation.NotImplementation;
import hub.annotation.View;
import hub.cathome.entity.Record;
import hub.cathome.entity.ShotBlog;
import hub.cathome.service.RecordService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;
@Deprecated
@Controller
public class RecordController {
    @Resource(name="recordService")
    private RecordService recordService;
    @View("档案视图")
    @GetMapping("/open/records")
    public String ShowRecords(Model model){
        List<Record> recordList = recordService.getAllRecord();
        model.addAttribute("recordList",recordList);
        return "open/records";
    }
    @View("详细档案视图")
    @GetMapping("/open/record/{recordId}")
    public String ShowRecordDetail(@PathVariable Integer recordId,Model model){
        Record record = recordService.getRecordById(recordId);
        model.addAttribute("record",record);
        return "open/record";
    }
    @View("编辑档案视图")
    @GetMapping("/open/record/edit/{recordId}")
    public String editRecord(@PathVariable Integer recordId,Model model){
        Record record = recordService.getRecordById(recordId);
        model.addAttribute("record",record);
        return "open/record/edit";
    }
    @NotImplementation("还需鉴权")
    @Affairs("删除档案")
    @RequestMapping("/affair/record/delete/{recordId}")
    public String deleteRecord(@PathVariable Integer recordId){
        recordService.deleteRecord(recordId);
        return "redirect: /open/records";
    }
    @Affairs("新增档案")
    @GetMapping("/open/record/add")
    public String newRecordView(){
        return "open/record/add";
    }
    @Affairs("新增档案")
    @GetMapping("/affair/record/add/")
    public String publishRecord(){
        return "open/records";
    }
    @NotImplementation("数据获取以及数据填充没有实现")
    @Affairs("保存更新的档案")
    @RequestMapping("/affair/record/update/{recordId}")
    public String saveRecord(@PathVariable Integer recordId){
        return "redirect: /open/record/"+recordId;
    }
}
